package cn.tude.cn.tedu.cn.tedu;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class Test_List {
    public static void main(String[] args) {
         List<Integer> list=new ArrayList();
         list.add(100);
         list.add(500);
         list.add(600);
         list.add(200);
         list.add(200);
         list.add(null);

        System.out.println(list);
        list.add(5,
                999);
        System.out.println(list);
        System.out.println(list.get(6));
        System.out.println(list.lastIndexOf(200));//200最后一次出现的索引
        System.out.println(list.indexOf(200));//200第一次出现的索引
        System.out.println(list.remove(5));//移除20索引的元素
        System.out.println(list.set(0,666));//把0位置的元素替换成666,并返回被替换的元素100
        System.out.println(list.remove(Integer.valueOf(500)));
                List<Integer> list2      =    list.subList(2,5);
        System.out.println(list2);


       Iterator<Integer> ID= list.iterator();
       while(ID.hasNext()){
           System.out.println(ID.next());
       }
        ListIterator<Integer>it2=list.listIterator();
       while (it2.hasNext()){
           System.out.println(it2.next());
       }
       ListIterator<Integer>it3=list.listIterator();
        for (int i = 0; i <list.size(); i++) {
            Integer in  =    list.get(i);
            System.out.println(in);

        }

        for (Integer x:
          list) {
            System.out.println(x);

        }




    }
}
